<!DOCTYPE html>
<html>

<head>

    {include file="Public/header"}
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
    <style>
        .radio-inline input[type=radio] {
            margin-top: 4px
        }
    </style>
</head>

<body style="color:#333;padding:3px;" class="x_sorll">
<!-- 标题 -->
<div class="page-heade">
    <h2 class="title_color text-center">非常规促销取消</h2>
</div>
<!-- 标题 -->
<div>
    <div action="" class="form-inline">
        <table class="tab-content table-bordered table" border="1">
            <tr>
                <td>
                    <!-- <button class="btn-info btn" type="button" style="margin-right: 15px">导出Excel完整版</button><button class="btn btn-info">导出Excel打印版</button> -->
                </td>
            </tr>
        </table>

        <table class="table row-margin-top table-bordered bud_hei">
            <tr>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">主题</label></td>
                <td colspan="3">{$data.title}</td>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">状态</label></td>
                <td>{$data.status_title}</td>
            </tr>
            <tr>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">区域维度</label></td>
                <td colspan="5">{$data.arealat==1?'经销商':'网点'}</td>
            </tr>
            <tr>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">产品维度</label></td>
                <td colspan="5">{$data.productlat_title}</td>
            </tr>
            <tr>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">申请人</label></td>
                <td>{$data.cusername}</td>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">职位</label></td>
                <td>{$data.job}</td>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">创建时间</label></td>
                <td>{:date('Y-m-d',$data.ctime)}</td>
            </tr>
            <tr>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">分区</label></td>
                <td>{$data.zoning}</td>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">省份</label></td>
                <td>{$data.provice}</td>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">城市</label></td>
                <td>{$data.city}</td>
            </tr>
            <tr>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">经销商名称</label></td>
                <td colspan="3"><span class="font-bold">{$data.jxs_title} <a href="{:url('jxsview',['id'=>$data.jxs_id])}"><span
                        class="glyphicon glyphicon-zoom-in fangda" aria-hidden="true"></span></a></span></td>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">性质</label></td>
                <td>经销</td>
            </tr>
            <tr>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">编号</label></td>
                <td>{$data.sn}</td>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">原编号</label></td>
                <td><a href="javascript:;">201709240014</a></td>
                <td style="min-width: 120px;width: 120px"><label for="" class="form-label">修改后编号</label></td>
                <td>无</td>
            </tr>
            <tr>
                <td colspan="6" class="text-left">
                    {$data.brief}
                </td>
            </tr>
        </table>
        <table class="table row-margin-top table-bordered text-center bud_hei" id="table1">
            <tr>
                <th class="font-bold text-center" style="font-size:20px" colspan="33">费用规划内容(金额单位：元)</th>
            </tr>
            <tr class="info">
                <th class="text-center">状态</th>
                <th class="text-center">审批人</th>
                <th class="text-center">序号</th>
                <th class="text-center">明细编号</th>
                <th class="text-center">经销商名称</th>
                <th class="text-center">品牌</th>
                <th class="text-center">活动执行时间</th>
                <th class="text-center">异动活动执行时间</th>
                <th class="text-center">预计核销时间</th>
                <th class="text-center">三级费用科目</th>
                <th class="text-center">未税费用金额</th>
                <th class="text-center">税率</th>
                <th class="text-center">是否增值税</th>
                <th class="text-center">含税费用金额</th>
                <th class="text-center">实际投入费用</th>
                <th class="text-center">费用支付方式</th>
                <th class="text-center">预计销量</th>
                <th class="text-center">预计费用率</th>
                <th class="text-center">2SR基准销量</th>
                <th class="text-center">基准销量</th>
                <th class="text-center">预计ROI</th>
                <th class="text-center">收款方</th>
                <th class="text-center">备注</th>
                <th class="text-center">取消原因<span class="colorRed">*</span>
                    <button class="btn btn-info " type="button" id="cancelBtn">取消整单</button>
                </th>
            </tr>
            <tbody>
            {volist name="data.list" id="row" key="k"}
            <tr data-id="{$row.id}">
                <td>{if $row.status==0}正常{/if}</td>
                <td>无</td>
                <td>{$k}
                    {if $row.ctime>$row.start}
                    <span class="colorRed duigou" title="此单申请时间在活动开始时间之后">补单</span>
                    {/if}
                </td>
                <td>
                    <a href="{:url('dataview',['id'=>$row.id])}">{$data.sn}_{$row.sn}</a>
                    <a href="{:url('decisionbasis',['id'=>''])}">
                            <span class="glyphicon glyphicon-zoom-in fangda" aria-hidden="true"
                                  style="display: inline-block;"></span>
                    </a>
                </td>
                <td>
                    {if $row.net_id}{$row.net_title}{else}{$row.jxs_title}<a href="{:url('jxsview',['id'=>$row.jxs_id])}"><span class="glyphicon glyphicon-zoom-in fangda"  aria-hidden="true" style="display: inline-block;"></span>{/if}</a>
                </td>
                <td>{$row.productlatval}</td>
                <td>从{:date('Y-m-d',$row.start)}至{:date('Y-m-d',$row.end)}</td>
                <td>
                    {if $row.ydstart&&$row.ydend}
                    从{:date('Y-m-d',$row.ydstart)}至{:date('Y-m-d',$row.ydend)}
                    {/if}
                </td>
                <td>{:date('Y-m-d',$row.expCanTime)}</td>
                <td>{$row.feetype}</td>
                <td class="ObjectNum">{$row.amount}</td>
                <td><span class="ObjectNum">0</span>%</td>
                <td>否</td>
                <td class="ObjectNum">6000</td>
                <td class="ObjectNum">6000</td>
                <td>账扣</td>
                <td class="ObjectNum">1400000</td>
                <td><span class="ObjectNum">0.43</span>%</td>
                <td class="ObjectNum">0</td>
                <td class="ObjectNum">1280000</td>
                <td><span class="ObjectNum">660</span>%</td>
                <td>{if $row.payee==0}(经销商){$row.jxs_title}{else}(供应商){$row.gys_name}{/if}</td>
                <td>{$row.brief}</td>
                <td><input type="text" class="form-control" style="width: 130px;height: 26px" name="reason"></td>
            </tr>
            {/volist}
            </tbody>
            <tr class="trTotal1 font-bold text-right">
                <td colspan="7">合计</td>
                <td></td>
                <td></td>
                <td></td>
                <td class="ObjectNum">6000</td>
                <td></td>
                <td></td>
                <td class="ObjectNum">6000</td>
                <td class="ObjectNum">6000</td>
                <td></td>
                <td class="ObjectNum">1400000</td>
                <td><span class="ObjectNum">0.43</span>%</td>
                <td class="ObjectNum">0</td>
                <td class="ObjectNum">1280000</td>
                <td><span class="ObjectNum">660</span>%</td>
                <td colspan="3"></td>
            </tr>
        </table>
        <div class="contact-box">
            <p class="font-bold">
                本申请中包含{if $data.net_cnt}{$data.net_cnt}个网点，{/if}{if $data.brand_cnt}{$data.brand_cnt}个品牌，{/if}{if $data.category_cnt}{$data.category_cnt}个品类，{/if}{if $data.category_cnt}{$data.category_cnt}个品类，{/if}{if $data.series_cnt}{$data.series_cnt}个系列，{/if}{if $data.sku_cnt}{$data.sku_cnt}个sku，{/if}{if $data.product_cnt}{$data.product_cnt}个单品，{/if}{if $data.feetype_cnt}{$data.feetype_cnt}个三级费用科目，{/if}其中路演费:334432.98元；调研费:5523.30元;总预计费用:41232.28元;总预计销量:777777.00元;总预计费用率:5.30%;总ROI:890.80%;
            </p>
        </div>
        <div class="form-group white-bg" style="margin:20px 10px 20px 20px;">
            {if isset($attach)}
            <ul class="list-group">
                {volist name="attach" id="row"}
                <li class="list-group-item">
                    <a class="badge badge-primary removeIt" data-id="{$row.id}">移除</a>
                    <a href="{$row.path}" target="_blank">{$row.file_name}</a></li>
                {/volist}
            </ul>
            {/if}
            <div id="uploader" class="wu-example">
                <!--用来存放文件信息-->
                <div id="thelist" class="uploader-list"></div>
                <div class="btns">
                    <div id="picker">选择文件</div>
                    <button id="ctlBtn" class="btn btn-default">开始上传</button>
                </div>
                <input type="hidden" name="attach" id="attach">
                <input type="hidden" name="remove" id="remove">
            </div>
            <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
        </div>
        <div class="row text-center padding-10">
            <button class="btn btn-primary save" id="save1">保存为草稿</button>
            <button class="btn btn-warning save" id="save2">保存并提交工作流</button>
            <button class="btn btn-info" onclick="location.href='{:url("index")}';return false;">返回</button>
        </div>
    </div>
</div>
{include file="Public/footer"}

<!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
<script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
<script src="__STATIC__/layout/js/common.js"></script>
<script>
    $(document).ready(function () {
        var $ObjectNum = $(".ObjectNum");
        toNum($ObjectNum);

        /*取消整单按钮*/
        $("#cancelBtn").click(function () {
            var str = '<div method="get" class="form-inline" style="margin:10px"><table class="table-bordered table"><tr><th class="info text-center" colspan="2">取消整单</th></tr><tr><td style="min-width:120px;width:120px;" class="text-center">取消原因<span class="colorRed">*</span></td><td><input type="text" name="zhengdanreason" class="form-control" style="min-width:400px;" /></td></tr></table> <div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0"><input type="submit" class="btn btn-success" value="确定" id="zhengdanquxiao"><input type="button" class="btn btn-warning" value="返回" id="cancelBack" style="margin-left:20px"></div></div>'
            layer.open({
                type: 1,
                title: "",
                skin: 'layui-layer-rim', //加上边框
                area: ['800px', '540px'], //宽高
                content: str
            });
            var cancelBack = document.getElementById('cancelBack')
            cancelBack.onclick = function () {
                layer.closeAll();
            }
        });

        //保存为草稿
        $('.save').on('click',function () {
            var flag = 0
            $("[name=reason]").each(function(){
                if($(this).val()!=""){
                    flag=1;
                }
            })
            if(flag==0){
                swal({
                    title: "错误",
                    text:  "至少一条明细发生取消",
                    type: "warning"
                });
            }else {
                var data = []
                $('[name=reason]').filter(function () {

                    return $(this).val()!=''

                }).closest('tr').each(function (i,o) {
                    var id = $(o).data('id')
                    var reason = $(o).find('[name=reason]').val()
                    data.push({
                        id:id,
                        reason:reason
                    })
                })
                var attach = $('#attach').val()
                var remove = $('#remove').val()
                var savetype = $(this).prop('id')
                $.post('',{data:data,attach:attach,remove:remove,type:savetype},function (data) {
                    if(data.success){
                        swal({
                            title:data.msg,
                            type:'success'
                        },function () {
                            location.href='{:url("index")}'
                        })
                    }else
                        swal(data.msg, "", "error");
                },'json')
            }

        })

        //整单取消
        $('body').on('click','#zhengdanquxiao',function () {
            var zhengdanreason = $('[name=zhengdanreason]').val()
            if(zhengdanreason==''){
                swal('请填写取消原因', "", "error");
                return false
            }
            $('[name=reason]').val(zhengdanreason)
            layer.closeAll();
        })
    })
</script>

<!-- Web Uploader -->
<script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
</script>
<script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>
<script>
    // 文件上传
    jQuery(function() {
        var $ = jQuery,
            $list = $('#thelist'),
            $btn = $('#ctlBtn'),
            state = 'pending',
            uploader;

        var ids = [];
        uploader = WebUploader.create({

            // 不压缩image
            resize: false,

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: '{:url("upload/fileupload")}',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker'
        });

        // 当有文件添加进来的时候
        uploader.on( 'fileQueued', function( file ) {
            $list.append( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>' );
        });

        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo( $li ).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css( 'width', percentage * 100 + '%' );
        });

        uploader.on( 'uploadSuccess', function( file,response) {
            if(response.success)
                ids.push(response.id)
            $( '#'+file.id ).find('p.state').text(response.msg);
        });

        uploader.on( 'uploadError', function( file ) {
            $( '#'+file.id ).find('p.state').text('上传出错');
        });

        uploader.on( 'uploadComplete', function( file ) {
            $('#attach').val(ids.join(','))
            $( '#'+file.id ).find('.progress').fadeOut();
        });

        uploader.on( 'all', function( type ) {
            if ( type === 'startUpload' ) {
                state = 'uploading';
            } else if ( type === 'stopUpload' ) {
                state = 'paused';
            } else if ( type === 'uploadFinished' ) {
                state = 'done';
            }

            if ( state === 'uploading' ) {
                $btn.text('暂停上传');
            } else {
                $btn.text('开始上传');
            }
        });

        $btn.on( 'click', function() {
            if ( state === 'uploading' ) {
                uploader.stop();
            } else {
                uploader.upload();
            }
            return false
        });

    });
</script>
</body>

</html>
